package com.hdaccp.xingmu.controller;

import com.hdaccp.xingmu.dao.JfxqDao;
import com.hdaccp.xingmu.entity.Jfxq;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/jfxq")
public class JfxqCon {
    @Autowired
    private JfxqDao jfxqDao;

    @PersistenceContext
    private EntityManager entityManager ;

    @RequestMapping("/add")
    @ResponseBody
    public Jfxq add(Jfxq jfxq){
        return jfxqDao.save(jfxq);

    }


    @RequestMapping("/quanbujianyi")
    @ResponseBody
    public List<Jfxq> quanbujinayi(int name) {
        String jpal="FROM Jfxq WHERE orderid='"+name+"'";
        Query qu = entityManager.createQuery(jpal);

        List<Jfxq> list = qu.getResultList();

        return list;


    }


}
